package facade;

import java.util.List;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.Query;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import entidad.Errores;

/**
 * Session Bean implementation class erroresFacade
 */
@Stateless
@LocalBean
public class ErroresFacade implements ErroresFacadeRemote {
	@PersistenceContext(unitName = "sgh001EJB")
	private EntityManager em;
    /**
     * Default constructor. 
     */
    public ErroresFacade() {
        // TODO Auto-generated constructor stub
    }
    @Override
    public List<Errores> listar(){
    	Query query=em.createQuery("SELECT e FROM Errores e ");
    	//@SuppressWarnings("unchecked")
    	return query.getResultList();
    }
    
    @Override
    public String searchCodError(int codError) {
    	Errores error=em.find(Errores.class, codError);
    	return error.getMensaje();
    		
    	
    }
    
}
